package conf

import "github.com/e421083458/golang_common/lib"

type Base struct {
	DebugMode    string
	TimeLocation string
	Host         string
}

var BaseConf Base

func GetBase() {
	conf := &BaseConf
	conf.DebugMode = lib.GetStringConf("base.base.debug_mode")
	conf.TimeLocation = lib.GetStringConf("base.base.time_location")
	conf.Host = lib.GetStringConf("base.base.host")
}

type Http struct {
	Addr           string
	ReadTimeout    int
	WriteTimeout   int
	MaxHeaderBytes int
	AllowIp        []string
}

var HttpConf Http

func GetHttp() {
	conf := &HttpConf
	conf.Addr = lib.GetStringConf("base.http.addr")
	conf.ReadTimeout = lib.GetIntConf("base.http.read_timeout")
	conf.WriteTimeout = lib.GetIntConf("base.http.write_timeout")
	conf.MaxHeaderBytes = lib.GetIntConf("base.http.max_header_bytes")
	conf.AllowIp = lib.GetStringSliceConf("base.http.allow_ip")
}

type JwtSecret struct {
	Secret     string
	ExpireTime int
}

var JwtSecretConf JwtSecret

func GetJwtSecret() {
	conf := &JwtSecretConf
	conf.Secret = lib.GetStringConf("base.JwtSecret.secret")
	conf.ExpireTime = lib.GetIntConf("base.JwtSecret.expire_time")
}

type Redis struct {
	ProxyList []string
	Password  string
	DB        int
	MaxActive int
	MaxIdle   int
}

var RedisConf Redis

func GetRedis() {
	conf := &RedisConf
	conf.ProxyList = lib.GetStringSliceConf("base.redis.proxy_list")
	conf.Password = lib.GetStringConf("base.redis.password")
	conf.DB = lib.GetIntConf("base.redis.db")
	conf.MaxActive = lib.GetIntConf("base.redis.max_active")
	conf.MaxIdle = lib.GetIntConf("base.redis.max_idle")
}

type MicroServer struct {
	Server []string
	Path []string
}

var MicroServerConf MicroServer

func GetMicroServer() {
	conf := &MicroServerConf
	conf.Server = lib.GetStringSliceConf("base.micro-server.server")
	conf.Path = lib.GetStringSliceConf("base.micro-server.path")
}